using System;
using FrameOperateSync;
using UnityEngine;

namespace Pvp
{
    [RequireComponent(typeof(IInputController))]
    public class PvpInput : MonoBehaviour
    {
        private IInputController input;
        [SerializeField]
        private int playerId = 101;

        private void Awake()
        {
            input = GetComponent<IInputController>();

            //  ClientRunningEvent.EventRolePick += (pid) => { playerId = pid; };

            input.MoveEvent += (x) =>  
            {
                Debug.LogError("ddkdjkf:"+x);
               // ClientUtility.SyncOperate(playerId, new MoveOperateData(x));
               // ClientUtility.SyncOperate(playerId,new KeyboardOperateData());
               if(x == 90)
                   ClientUtility.SyncOperate(playerId,new KeyboardOperateData(KeyCode.W));
               if(x == 180)
                   ClientUtility.SyncOperate(playerId,new KeyboardOperateData(KeyCode.A));
               if(x == -90)
                   ClientUtility.SyncOperate(playerId,new KeyboardOperateData(KeyCode.S));
               if(x == 0)
                   ClientUtility.SyncOperate(playerId,new KeyboardOperateData(KeyCode.D));
            };
            input.StopEvent += () => 
            {
                Debug.LogError("ddkdjkf:----");
                ClientUtility.SyncOperate(playerId,new KeyboardOperateData(KeyCode.Space));
            };
            input.ButtonEvent += (x) => 
            {
                ClientUtility.SyncOperate(playerId, new SkillOperateData(x));
            };
        }
    }
    
}